<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>01 运算符</title>
</head>
<body>
    
</body>
<script>
    //1.算数运算符
    let a = 5;
    let b = '8';
    let c = 3;
    console.log(a + b);//? 58 +:当运算符的一边有字符串的时候，此时就是字符串的拼接
    console.log(a + c);//? 8 +:运算符两侧都是数字的时候，就是相加

    console.log('国庆假期准备又来了：' + '1-7放假，8-9上课' + (c + a))

    console.log(a - b);//? 相减 - * / % 都会进行隐式转换：会帮你把字符串转成数字再相减

    //把字符串转成数字
    let aa = '8';
    // aa = aa - 0;
    // aa = aa * 1;
    console.log(typeof(aa))

    let jiben = '3000';
    let jixiao = '5000';
    let quanqin = '300';
    let xiangmu = '2000';

    console.log('工资：' + (jiben * 1 + jixiao * 1 + quanqin * 1 + xiangmu * 1))

    //取余数
    let num = 8;
    console.log(num % 3);//? 2

    //强制转换的方法：
    let total = '666.5';
    let total2 = parseInt(total); //强制把字符串转成数字(整数)
    let total3 = parseFloat(total);//强制把字符串转成数字(小数点)
    console.log(total2, total3)

    //战士作战时间 128小时，问：xx天xx小时
    let hours = 128;
    let day;
    let hour;
    day = parseInt(hours / 24)
    hour = hours % 24;
    console.log(hours / 24)

    console.log('128小时是：' + day + '天' + hour + '小时')

    //课堂作业：3.请把354456秒转成：xx时xx分xx秒
    let time = 354456;
    let hourss = parseInt(time / 3600);
    let mins = parseInt(time / 60 % 60); //72分  = 1时12分  72 % 60 = 12分 ; parseInt(72 /60) = 1
    let secs = time % 60;
    console.log(hourss + '时' + mins + '分' + secs + '秒')
</script>
</html>